package com.erp.module.peibanPcode

import android.content.Context
import com.erp.Interface.OnUserDataInterface
import com.erp.contacts.Contacts
import com.erp.util.Httputil
import com.erp.util.Myutil
import org.xutils.http.RequestParams
import org.xutils.x
import java.util.Date

class PeibanModel {
    /**获取堆号数据 */
    fun getDuihao(context: Context, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams(Contacts.PEIBAN_GET_DUIHAO)
        params.addBodyParameter("page", "1")
        params.addBodyParameter("page_size", "2000")
        params.addBodyParameter("sp[time_filter][time_category]", "duihao.productive_at")
        params.addBodyParameter("sp[time_filter][start_time]", Myutil.getjulidate2(-3))
        params.addBodyParameter("sp[time_filter][end_time]", Myutil.getjulidate2(3))
        Httputil.getparams(context, params)
        x.http().get<String>(params, Httputil.Call(context, onUserDataInterface))
    }

    /**创建堆号数据 */
    fun createPcode(context: Context, pcode: String, total: String, duihaoId: String, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams(Contacts.PEIBAN_CREATEPCODE)
        Httputil.getparams(context, params)
        params.addBodyParameter("pcode", pcode)
        params.addBodyParameter("total", total)
        params.addBodyParameter("duihaoId", duihaoId)
        x.http().post<String>(params, Httputil.Call(context, onUserDataInterface))
    }
}